package se.tinkerway.bomberman.domain.tile;

import se.tinkerway.bomberman.domain.Bomberman;
import se.tinkerway.bomberman.domain.Tile;
import se.tinkerway.bomberman.domain.TileCallback;
import se.tinkerway.bomberman.view.Appearance;
import se.tinkerway.bomberman.view.Frame;

public class Flame implements Tile {
	
	private static final int MAX_TIME = 1000;
	private long timeLeft;
	
	public Flame() {
		timeLeft = MAX_TIME;
	}
	
	@Override
	public boolean burn(TileCallback callback) {
		return true;
	}

	@Override
	public Frame getFrame() {
		return new Frame(MAX_TIME-timeLeft, Appearance.FLAME);
	}

	@Override
	public boolean isPassable() {
		return true;
	}

	@Override
	public void onEnter(Bomberman bomberman) {
		bomberman.die();
	}

	@Override
	public void timeTick(long deltaTime, TileCallback callback) {
		timeLeft -= deltaTime;
		if (timeLeft < 0) {
			callback.remove();
		}
	}

}
